﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using SAKS.Models;
using NHibernate.Criterion;
namespace SAKS.Services.Query
{
    class PagedOrganizationSearch : PagedQueryOverBase<Organization>
    {
        public PagedOrganizationSearch(ISession session) : base(session) { }
        public string Key { get; set; }
        protected override IQueryOver<Organization, Organization> GetQuery()
        {
            var query = Session.QueryOver<Organization>();
            if (!string.IsNullOrEmpty(Key))
                query = query.WhereRestrictionOn(o => o.Name).IsLike(Key, MatchMode.Anywhere);
            query = query.OrderBy(m => m.Name).Desc;
            return query;
        }
    }
}
